<?php
$conf = new DOMDocument(); 
$conf->load( 'fields_conf.xml' ); 

$xmlDoc = new DOMDocument();

$application = $_GET['app'] ;
 
$field = $_GET['field'] ;
 

$field_conf = $xmlDoc->appendChild($xmlDoc->createElement("app")); 
$apps = $conf->getElementsByTagName( "app" );
foreach( $apps as $app ) 
{
	$app_name = $app->getElementsByTagName( "name" )->item(0)->nodeValue; 
	if( $app_name == $application  )
	{
	
		$xml_fields = $app->getElementsByTagName( "field" );
	 
		foreach( $xml_fields as $xml_field ) 
		{
			$field_name = $xml_field->getElementsByTagName( "name" )->item(0);
			if( $field_name->nodeValue == $field  )
			{
				$field_values = $xml_field->getElementsByTagName( "values" )->item(0)->nodeValue;
				$xml_field_name = $field_conf->appendChild($xmlDoc->createElement("field"));			         	
				$xml_field_name->appendChild($xmlDoc->createElement("values", $field_values)); 
			}
		}	 
	} 
}
header("Content-Type: text/xml");
$xmlDoc->formatOutput = true;
echo $xmlDoc->saveXML(); 
?>
